//
//  RestoreViewController.m
//  DayByDay
//
//  Created by dllo on 16/5/29.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "RestoreViewController.h"
#import "DataHandle.h"
#import "PosterDetailSongsModel.h"
#import <UIImageView+WebCache.h>

@interface RestoreViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong)UITableView *tableView;
@property (nonatomic, strong)NSMutableArray *array;


@end

@implementation RestoreViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"我的收藏";
//    [self createData];
    [self createView];
    [self createData];
}

- (void)createData {
    self.array = [NSMutableArray arrayWithArray:[[DataHandle shareDataBaseHandle] selectPosterSongsModelFromTable:@"store"]];
    
    [self.tableView reloadData];
}

- (void)createView {
    self.tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
    [self.view addSubview:self.tableView];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.array.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class])];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:NSStringFromClass([UITableViewCell class])];
    }
    PosterDetailSongsModel *model = self.array[indexPath.row];
    cell.textLabel.text = model.name;
    cell.detailTextLabel.text = model.singerName;
    [cell.imageView sd_setImageWithURL:[NSURL URLWithString:model.picUrl]];
    NSLog(@"%@",model.picUrl);
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 100;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
